package com.geek.gkpush.dal.mapper;

import com.geek.gkpush.dal.bean.EventMsgDO;
import com.geek.gkpush.dal.model.EventMsgScanModel;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <h1>事件消息数据库 Mapper 接口。</h1><br/>
 *
 * <h1><br/><a href="https://u.geekbang.org/subject/arch3/100614201">Java 业务架构实战营：https://u.geekbang.org/subject/arch3/100614201</a></h1><br/><h1><a href="https://gitee.com/ylimhhmily/BizArchPracticeCamp">Java 业务架构实战营代码地址：https://gitee.com/ylimhhmily/BizArchPracticeCamp</a></h1><br/><h1><a href="https://u.geekbang.org/subject/java4th/1001148?source=app_share">高级 Java 工程体系课 2023 版：https://u.geekbang.org/subject/java4th/1001148?source=app_share</a></h1><br/><h1><a href="https://time.geekbang.org/column/intro/100312101?tab=catalog">Dubbo 源码剖析与实战：https://time.geekbang.org/column/intro/100312101?tab=catalog</a></h1>
 *
 * @author hmilyylimh
 *         ^_^
 * @version 0.0.1
 *         ^_^
 * @date 2023/10/2
 *
 */
public interface EventMsgMapper {

    /** <h2>插入数据</h2> **/
    public int insertObject(EventMsgDO eventMsgDO);

    /** <h2>批量插入数据</h2> **/
    public void batchInsertObject(@Param("list") List<EventMsgDO> eventMsgList);

    /** <h2>根据主键更新数据</h2> **/
    public int updateObjectByPK(EventMsgDO eventMsgDO);

    /** <h2>查询列表</h2> **/
    public List<EventMsgDO> queryForList(EventMsgDO eventMsgDO);

    /** <h2>查询记录数</h2> **/
    public int queryForInt(EventMsgDO eventMsgDO);

    /** <h2>根据主键查询对象</h2> **/
    public EventMsgDO queryObjectByPK(EventMsgDO eventMsgDO);

   /** <h2>根据 id 查找有效对象</h2> */
    public EventMsgDO queryObjectById(@Param("id") String id);

    /** <h2>根据时间等条件查询分片列表</h2> */
    public List<EventMsgDO> queryShardingListByRangeCreateTime(@Param("model") EventMsgScanModel model);

    /** <h2>根据 id + srcPushStatus 修改事件消息对象</h2> */
    public int updatePushStatusByCondition(@Param("msg") EventMsgDO eventMsgDO,
                                           @Param("srcPushStatus") String srcPushStatus);

    /** <h2>根据 bizId + bizType + srcPushStatus + maxTime + minTime 查询符合条件的记录</h2> */
    public List<EventMsgDO> queryListByRangeTime(@Param("bizType") String bizType,
                                                 @Param("bizId") String bizId,
                                                 @Param("srcPushStatus") String srcPushStatus,
                                                 @Param("maxTime") Long maxTime,
                                                 @Param("minTime") Long minTime);

    /** <h2>根据 idList + srcPushStatus 来更新列表</h2> */
    public int updateList2Succ(@Param("idList") List<String> idList,
                               @Param("srcPushStatus") String srcPushStatus,
                               @Param("pushResult") String pushResult);
}